// 入库制单
import React from 'react';
import { Card, Row, Col, Form, DatePicker, Select, Switch, Input, Button, message, Popconfirm, Upload, Tooltip, Icon, Menu, Dropdown } from 'antd';
import { $http } from 'containers/config/https';
import { Util } from 'tools'
import Moment from 'moment';
import DetailEntryList from './component/DetailEntryList.jsx';
import InquireWarehouseVoucher from './component/InquireWarehouseVoucher.jsx';
import './style/index.less';
import * as XLSX from 'xlsx';
import { printInOp } from '../pharmacy/commonPrint/stkPrint';
import AccordingToWarehouse from "./component/AccordingToWarehouse";
import AccordingToChecked from "./component/AccordingToChecked";
// const { printInOp }=stkPrint;
let timeout;
const { Option } = Select;
// function isObjEqual(o1, o2) {
//     var props1 = Object.getOwnPropertyNames(o1);
//     var props2 = Object.getOwnPropertyNames(o2);
//     if (props1.length != props2.length) {
//         return false;
//     }
//     for (var i = 0, max = props1.length; i < max; i++) {
//         var propName = props1[i];
//         if (o1[propName] !== o2[propName]) {
//             return false;
//         }
//     }
//     return true;
// }
const WarehouseVoucher = Form.create()(
    class extends React.Component {
        constructor() {
            super();
            this.state = {
                userInfo: {},
                SelectData: {}, // 下拉框数据
                detailInfo: [], // 明细列表数据
                rowId: '', // 入库单Id
                tacitlyApproveData: {}, // 界面的默认数据
                inOperLocID: "",
                completeStatus: 0, // 完成取消完成按钮操作状态
                stkCatID: '',
                ChineseEnglishSize: {}, //中英翻译
                language: JSON.parse(window.sessionStorage.userData),
                inOpTypeID: '', //入库类型初始值
                supplierData: [],
                wardID: undefined,
                wardSelectData: [],
            };
            this.myRef1 = React.createRef();
            this.myRef2 = React.createRef();
            this.myRef3 = React.createRef();
            this.myRef4 = React.createRef();
            this.myRef5 = React.createRef();
            this.myRef6 = React.createRef();
            this.myRef7 = React.createRef();
            this.myRef8 = React.createRef();
            this.myRef9 = React.createRef();
        }

        componentDidMount() {
            // 初始化数据
            this.getSelectData();
            this.getTacitlyApproveData();
            this.getInOperLocID();
        }

        componentWillUnmount() {
            // 组件销毁前将静止让setState修改state的状态
            this.setState = (state, callback) => { return; }
        }

        onRef = (ref) => {
            this.childModal = ref;
        }

        detailOnRef = (ref) => {
            this.childDetail = ref;
        };

        // 获取下拉框的数据
        getSelectData() {
            let data = {
                params: []
            }
            $http.post('urlS', this, {
                code: "02020041",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({ SelectData: res.result[0], inOpTypeID: res.result[0] ? (res.result[0].inOpType && res.result[0].inOpType[0] ? res.result[0].inOpType[0].id : '') : '' })
                    } else {
                        this.setState({ SelectData: {} })
                    }
                }
            })
        }

        onPressEnterData = (v) => {
            let data = {
                params: [{
                    desc: v.target.value
                }]
            }
            $http.post('urlS', this, {
                code: "02020352",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({ supplierSelect: res.result })
                    }
                }
            })
        };

        handleWardSelectData = (value) => {
            if (timeout) {
                clearTimeout(timeout);
                timeout = null;
            }
            timeout = setTimeout(() => {
                if (value) {
                    let data = {
                        params: [{
                            desc: value
                        }]
                    }
                    $http.post('urlS', this, {
                        code: "02020353",
                        data: data,
                        success: function (res) {
                            if (+res.errorCode === 0) {
                                this.setState({ wardSelectData: res.vendor })
                            }
                        }
                    })
                }
            }, 300)
        };

        handleWardOnChange = e => {
            this.setState({ wardID: e }, () => {
                // this.getWardTableData()
            })
        }

        // 保存
        saveHandle = () => {
            let statusID = this.props.form.getFieldValue('statusID');
            if (+statusID < 20 || !statusID) {
                if (this.childDetail.state.data.length < 1) {
                    message.error("明细列表不能为空")
                } else {

                    // if (this.childDetail.state.stockID) {
                    //     let newObj = this.childDetail.checkFormData();
                    //     let beforeObj = this.childDetail.initialDataObj();
                    //     if (!isObjEqual(newObj, beforeObj)) {
                    //         message.error('有未保存的数据，请先保存');
                    //         return
                    //     }
                    // }
                    const { form: { validateFields } } = this.props;
                    validateFields((errors, values) => {
                        // 验证成功
                        if (errors === null) {
                            let data = {
                                params: []
                            }
                            let child = {
                                mianInfo: [],
                                detailInfo: this.childDetail.state.data
                            }
                            let obj = JSON.parse(JSON.stringify(values));
                            // 将开关的值转化
                            obj.StartDate = Moment(obj.StartDate).format('YYYY-MM-DD');
                            obj.adjCheque = Util.replaceTrueFalse(obj.adjCheque);
                            obj.giftFlag = Util.replaceTrueFalse(obj.giftFlag);
                            obj.inOperID = this.state.rowId ? this.state.rowId : undefined;
                            obj.vendorID = !isNaN(obj.vendorID) ? obj.vendorID : this.state.userInfo.vendorID;
                            child.mianInfo.push(obj);
                            data.params.push(child);
                            $http.post('urlADS', this, {
                                code: "02020046",
                                data: data,
                                success: function (res) {
                                    if (+res.errorCode === 0) {
                                        // 成功提示
                                        message.success(res.errorMessage);
                                        this.resetFieldsFrom()
                                        if (res.result[0]) {
                                            this.getEchoData(res.result[0].inOperID);
                                        }
                                    }
                                }
                            })
                        }
                    })
                }
            } else {
                message.error("当单据状态为保存或者为空时才可以进行操作");
            }
        }

        // 保存成功后根据返回回来的inOperID重新查找数据
        getEchoData(id) {
            // 重置表单
            this.props.form.resetFields(); //清空所有
            this.setState({ rowId: id }); // 将行id保存起来
            let data = {
                params: [
                    {
                        inOperID: id
                    }
                ]
            }
            $http.post('urlS', this, {
                code: "02020048",
                data: data,
                success: function (res) {
                    // console.log(res)
                    if (+res.errorCode === 0) {
                        for (let i = 0; i < res.result[0].detailInfo.length; i++) {
                            res.result[0].detailInfo[i].key = i + "main";
                        }
                        this.setState({ userInfo: res.result[0].mainInfo[0], detailInfo: res.result[0].detailInfo, completeStatus: res.result[0].mainInfo[0].statusID });
                        // this.props.form.setFieldsValue(res.result[0].mainInfo[0]); // 将查询出来的数据回显
                    } else {
                        this.setState({ userInfo: {}, detailInfo: [] });
                    }
                }
            })
        }

        //子组件依据订单保存后回调的方法的
        childAccordingToData = (val) => {
            // console.log('回调方法',val)
            this.setState({ userInfo: val[0].mainInfo, detailInfo: val[0].detailInfo });
        }

        // 获取到入库科室的值
        getInOperLocID() {
            let inOperLocID = this.props.form.getFieldValue('inOperLocID');
            this.setState({ inOperLocID: inOperLocID });
        }

        // 点击查询显示弹框
        inquireHandle = () => {
            // let inOperLocID = this.getInOperLocID();
            if (this.state.inOperLocID) {
                this.childModal.showModal(this.state.ChineseEnglishSize);
            } else {
                message.info("请先选择入库科室");
            }
        }

        // 重置明细录入
        resetFieldsFrom() {
            this.childDetail.resetFields();
        }

        // 重置所有内容
        resetFieldsAll() {
            this.props.form.resetFields(); //清空所有
            this.setState({ userInfo: {}, detailInfo: [], rowId: "", stkCatID: '', inOpTypeID: '' });
            this.childDetail.resetFields();
            this.childDetail.deleteData();
            this.childModal.handleUncheck();
        }

        // 重置表单
        resetFields = () => {
            this.resetFieldsAll()
            // let statusID = this.props.form.getFieldValue('statusID');
            // // console.log(statusID)
            // if (+statusID < 20 || statusID === undefined) {
            //     // console.log("触发了")
            //     this.resetFieldsAll()
            // } else {
            //     message.error("单据状态为保存或者为空时才允许此操作")
            // }
        }

        // 设置单据状态
        setDocumentStatus(statusCode, flag) {
            let data = {
                params: [
                    {
                        inOperID: this.state.rowId,
                        statusID: statusCode
                    }
                ]
            }
            $http.post('urlS', this, {
                code: "02020051",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        message.success(res.errorMessage);
                        this.getEchoData(res.result[0].inOperID);
                        if (flag === 'complete') {
                            this.setState({ completeStatus: 10 })
                        } else if (flag === 'cancelComplete') {
                            this.setState({ completeStatus: 20 })
                        }
                        // this.detailOnRef.deleteData(); // 保存成功后清空明细列表数据
                        // this.setState({detailInfo: []})
                    }
                }
            })
        }

        // 完成
        handleComplete = () => {
            this.setDocumentStatus(20, 'complete');
        }

        // 取消完成
        handleCancelComplete = () => {
            this.setDocumentStatus(10, 'cancelComplete');
        }

        // 删除
        handleDelete = () => {
            let { ChineseEnglishSize } = this.state;
            let statusID = this.props.form.getFieldValue('statusID');
            if (+statusID < 20) {
                let data = {
                    params: [
                        {
                            inOperID: this.state.rowId,
                        }
                    ]
                }
                $http.post('urlS', this, {
                    code: "02020052",
                    data: data,
                    success: function (res) {
                        if (+res.errorCode === 0) {
                            message.success(res.errorMessage);
                            this.resetFieldsAll();
                        }
                    }
                })
            } else {
                message.error(ChineseEnglishSize.WarehousingOrderMakingoperateTips ? ChineseEnglishSize.WarehousingOrderMakingoperateTips.message : '当单据状态为保存时才可以进行操作');
            }
        }

        // 获取界面默认值
        getTacitlyApproveData() {
            let data = {
                params: []
            }
            $http.post('urlS', this, {
                code: "02020054",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({ tacitlyApproveData: res.result[0] })
                    } else {
                        this.setState({ tacitlyApproveData: {} })
                    }
                }
            })
        }

        // 导入
        beforeUpload = (file, fileList) => {
            let { ChineseEnglishSize } = this.state;
            var rABS = true;
            const f = fileList[0];
            var reader = new FileReader();
            reader.onload = event => {
                try {
                    const { result } = event.target;
                    // 以二进制流方式读取得到整份excel表格对象
                    const workbook = XLSX.read(result, { type: 'binary' });
                    // 存储获取到的数据
                    let data = [];
                    // 遍历每张工作表进行读取（这里默认只读取第一张表）
                    for (const sheet in workbook.Sheets) {
                        // esline-disable-next-line
                        if (workbook.Sheets.hasOwnProperty(sheet)) {
                            // 利用 sheet_to_json 方法将 excel 转成 json 数据
                            data = data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet]));
                            // break; // 如果只取第一张表，就取消注释这行
                        }
                    }
                    // 最终获取到并且格式化后的 json 数据
                    // console.log(data)
                    this.disposeImportData(data)
                    // this.setState({excelData: data});
                } catch (e) {
                    // 这里可以抛出文件类型错误不正确的相关提示
                    message.error(ChineseEnglishSize.WarehousingOrderMakingfileTypeIsNotCorrect ? ChineseEnglishSize.WarehousingOrderMakingfileTypeIsNotCorrect.message : '文件类型不正确');
                }
            };
            if (rABS) reader.readAsBinaryString(f); else reader.readAsArrayBuffer(f);
            return false;
        }

        // 处理导入的数据
        disposeImportData(data) {
            let { ChineseEnglishSize } = this.state;
            let filterData = [];
            for (let i = 0; i < data.length; i++) {
                if (data[i].药品代码 && data[i].生产企业 && data[i].数量 && data[i].进价 && data[i].售价) {
                    filterData.push(data[i])
                }
            }
            if (filterData.length > 0) {
                let excelData = filterData && filterData.map((item, index) => {
                    return {
                        stockCode: item.药品代码 ? item.药品代码 : '', // 药品代码
                        stockDesc: item.药品名称 ? item.药品名称 : '', // 药品名称
                        manfDesc: item.生产企业 ? item.生产企业 : '', // 生产企业
                        batNo: item.批号 ? item.批号 : '', // 批号
                        expDate: item.有效期 ? item.有效期 : '', // 有效期
                        qty: item.数量 ? item.数量 : '', // 数量
                        rp: item.进价 ? item.进价 : '', // 进价
                        sp: item.售价 ? item.售价 : '', // 售价
                        invNo: item.发票号 ? item.发票号 : '', // 发票号
                        invDate: item.发票日期 ? item.发票日期 : '', // 发票日期
                        qualityNo: item.质检单号 ? item.质检单号 : '', // 质检单号
                        produceDate: item.生产日期 ? item.生产日期 : '', // 生产日期
                        remark: item.备注 ? item.备注 : '', // 备注
                        key: index + "import",
                    }
                })
                this.setState({ detailInfo: excelData })
                for (var i = 0; i < excelData.length; i++) {
                    excelData[i].stockCode && this.getStockID(excelData[i].stockCode);
                    excelData[i].manfDesc && this.getmanfID(excelData[i].manfDesc)
                }
            } else {
                message.error(ChineseEnglishSize.WarehousingOrderMakingfilesWithErrors ? ChineseEnglishSize.WarehousingOrderMakingfilesWithErrors.message : '文件内容有误，内容必须包含药品代码、生产企业、数量、进价、售价等列')
            }
        }

        // 获取库存项id
        getStockID(stockCode) {
            let data = {
                params: [
                    {
                        stockCode: stockCode,
                    }
                ]
            }
            $http.post('urlS', this, {
                code: "02020064",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        let detailInfo = [...this.state.detailInfo]
                        for (let i = 0; i < detailInfo.length; i++) {
                            if (detailInfo[i].stockCode === stockCode) {
                                detailInfo[i].stockID = res.result[0].stockID
                            }
                        }
                        this.setState({ detailInfo: detailInfo })
                    }
                }
            })
        }

        // 获取生产企业id
        getmanfID(manfDesc) {
            let data = {
                params: [
                    {
                        manfDesc: manfDesc,
                    }
                ]
            }
            $http.post('urlS', this, {
                code: "02020065",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        let detailInfo = [...this.state.detailInfo]
                        for (let i = 0; i < detailInfo.length; i++) {
                            if (detailInfo[i].manfDesc === manfDesc) {
                                detailInfo[i].manfID = res.result[0].manfID
                            }
                        }
                        this.setState({ detailInfo: detailInfo })
                    }
                }
            })
        }

        // 下拉框选中事件
        handleOnSelect = (num) => {
            switch (num) {
                case 1:
                    setTimeout(() => {
                        this.myRef2.current.focus();
                    }, 300)
                    break;
                case 2:
                    setTimeout(() => {
                        this.myRef3.current.focus();
                    }, 300)
                    break;
                case 3:
                    setTimeout(() => {
                        this.myRef4.current.focus();
                    }, 300)
                    break;
                case 4:
                    setTimeout(() => {
                        this.myRef5.current.focus();
                    }, 300)
                    break;
                case 5:
                    setTimeout(() => {
                        this.myRef6.current.focus();
                    }, 300)
                    break;
                case 6:
                    setTimeout(() => {
                        this.myRef7.current.focus();
                    }, 300)
                    break;
                case 7:
                    setTimeout(() => {
                        this.myRef8.current.focus();
                    }, 300)
                    break;
                case 8:
                    setTimeout(() => {
                        this.myRef9.current.focus();
                    }, 300)
                    break;
                default:
                    setTimeout(() => {
                        this.myRef1.current.focus();
                    }, 300)
            }
        };

        onWarehouseRef = (ref) => {
            this.childWarehouse = ref;
        };

        onCheckedRef = (ref) => {
            this.childChecked = ref;
        };

        //显示依据订单弹窗
        warehouseRequest = () => {
            this.childWarehouse.showModal(this.state.ChineseEnglishSize);
        };

        //显示依据消耗弹框
        checkedVoucher = () => {
            this.childChecked.showModal(this.state.ChineseEnglishSize);
        };

        changeStkCat = (v) => {
            this.setState({ stkCatID: v, inOperLocID: this.props.form.getFieldValue('inOperLocID') })
        };

        changesDesc = (v) => {
            this.setState({ stkCatID: this.props.form.getFieldValue('stkCatID'), inOperLocID: v })
        };

        //获取中英版
        getChineseEnglishSize = (v) => {
            this.setState({ ChineseEnglishSize: v })
        };

        render() {
            const uploadprops = {
                // 这里我们只接受excel2007以后版本的文件，accept就是指定文件选择框的文件类型
                accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                name: 'file',
                headers: {
                    authorization: 'authorization-text',
                },
                showUploadList: false,
                // 把excel的处理放在beforeUpload事件，否则要把文件上传到通过action指定的地址去后台处理
                // 这里我们没有指定action地址，因为没有传到后台
                beforeUpload: this.beforeUpload
            };
            const formItemInput = {
                labelCol: {
                    xs: { span: 9 },
                    sm: { span: 10 },
                    md: { span: 6 }
                },
                wrapperCol: {
                    xs: { span: 15 },
                    sm: { span: 14 },
                    md: { span: 18 }
                },
            };
            const formItemSwitch = {
                labelCol: { span: 12 },
                wrapperCol: { span: 12 },
            };
            const { getFieldDecorator } = this.props.form;
            let userInfo = this.state.userInfo ? this.state.userInfo : {};
            let user = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
            let completeStatus = +this.state.completeStatus === 10 ? false : true;
            let cancelCompleteStatus = +this.state.completeStatus === 20 ? false : true;
            let { ChineseEnglishSize, wardSelectData, wardID } = this.state;
            let wardAreaOption = wardSelectData && wardSelectData.map((item, index) => {
                return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
            });
            const menu = (
                <Menu>
                    <Menu.Item>
                        <a rel="noopener noreferrer" onClick={this.warehouseRequest} >
                            {ChineseEnglishSize.WarehousingOrderMakingaccordingToOrders ? ChineseEnglishSize.WarehousingOrderMakingaccordingToOrders.descripts : '依据订单'}
                        </a>
                    </Menu.Item>
                    <Menu.Item>
                        <a rel="noopener noreferrer" onClick={this.checkedVoucher} >
                            {ChineseEnglishSize.WarehousingOrderMakingauditedReceipts ? ChineseEnglishSize.WarehousingOrderMakingauditedReceipts.descripts : '已审核入库单'}
                        </a>
                    </Menu.Item>
                </Menu>
            );
            return (
                <div className="warehouse-voucher">
                    <Card
                        size="small"
                        title={<div className="card-title-left-icon"><div></div> {ChineseEnglishSize.WarehousingOrderMakinginboundForm ? ChineseEnglishSize.WarehousingOrderMakinginboundForm.descripts : '入库制单'}</div>}
                    // extra={<a href="#">More</a>}
                    >
                        <Row>
                            <Col span={18} className="top-form">
                                <Form>
                                    <Row>
                                        <Col span={8} style={{ paddingRight: '10px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakinginOperLocID ? ChineseEnglishSize.WarehousingOrderMakinginOperLocID.descripts : '入库科室'} {...formItemInput}>
                                                {getFieldDecorator('inOperLocID', {
                                                    initialValue: userInfo.inOperLocID ? userInfo.inOperLocID : user.locID,
                                                    rules: [{ required: ChineseEnglishSize.WarehousingOrderMakinginOperLocID ? ChineseEnglishSize.WarehousingOrderMakinginOperLocID.required == 'Y' ? true : false : false, message: ChineseEnglishSize.WarehousingOrderMakinginOperLocID ? ChineseEnglishSize.WarehousingOrderMakinginOperLocID.message : '科室不能为空' }]
                                                })(
                                                    <Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.WarehousingOrderMakingpleaseChoose && ChineseEnglishSize.WarehousingOrderMakinginOperLocID ? (ChineseEnglishSize.WarehousingOrderMakingpleaseChoose.descripts + ChineseEnglishSize.WarehousingOrderMakinginOperLocID.descripts) : '请选择入库科室'} ref={this.myRef1} onSelect={(v) => { this.handleOnSelect(1); this.changesDesc(v) }}>
                                                        {this.state.SelectData.inOpLoc && this.state.SelectData.inOpLoc.map(item => {
                                                            return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8} style={{ paddingRight: '10px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingoperTypeID ? ChineseEnglishSize.WarehousingOrderMakingoperTypeID.descripts : '入库类型'} {...formItemInput}>
                                                {getFieldDecorator('operTypeID', {
                                                    initialValue: userInfo.operTypeID ? userInfo.operTypeID : this.state.inOpTypeID,
                                                    rules: [{ required: ChineseEnglishSize.WarehousingOrderMakingoperTypeID ? ChineseEnglishSize.WarehousingOrderMakingoperTypeID.required == 'Y' ? true : false : false, message: ChineseEnglishSize.WarehousingOrderMakingoperTypeID ? ChineseEnglishSize.WarehousingOrderMakingoperTypeID.message : '请选择入库类型' }]
                                                })(
                                                    <Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.WarehousingOrderMakingpleaseChoose && ChineseEnglishSize.WarehousingOrderMakingoperTypeID ? (ChineseEnglishSize.WarehousingOrderMakingpleaseChoose.descripts + ChineseEnglishSize.WarehousingOrderMakingoperTypeID.descripts) : '请选择入库类型'} ref={this.myRef2} onSelect={() => this.handleOnSelect(2)}>
                                                        {this.state.SelectData.inOpType && this.state.SelectData.inOpType.map(item => {
                                                            return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8} style={{ paddingRight: '30px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingpurUserID ? ChineseEnglishSize.WarehousingOrderMakingpurUserID.descripts : '采购人员'} {...formItemInput}>
                                                {getFieldDecorator('purUserID', {
                                                    initialValue: userInfo.purUserID ? userInfo.purUserID : undefined,
                                                })(
                                                    <Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.WarehousingOrderMakingpleaseChoose && ChineseEnglishSize.WarehousingOrderMakingpurUserID ? (ChineseEnglishSize.WarehousingOrderMakingpleaseChoose.descripts + ChineseEnglishSize.WarehousingOrderMakingpurUserID.descripts) : '请选择采购人员'} ref={this.myRef3} onSelect={() => this.handleOnSelect(3)}>
                                                        {this.state.SelectData.purPlanUser && this.state.SelectData.purPlanUser.map(item => {
                                                            return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={8} style={{ paddingRight: '10px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingvendorID ? ChineseEnglishSize.WarehousingOrderMakingvendorID.descripts : '供应商'} {...formItemInput}>
                                                {getFieldDecorator('vendorID', {
                                                    initialValue: userInfo.vendorDesc ? userInfo.vendorDesc : wardID,
                                                    rules: [{ required: ChineseEnglishSize.WarehousingOrderMakingvendorID ? ChineseEnglishSize.WarehousingOrderMakingvendorID.required == 'Y' ? true : false : false, message: ChineseEnglishSize.WarehousingOrderMakingvendorID ? ChineseEnglishSize.WarehousingOrderMakingvendorID.message : '请选择供应商' }]
                                                })(
                                                    <Select
                                                        showSearch
                                                        defaultActiveFirstOption={false}
                                                        showArrow={false}
                                                        filterOption={false}
                                                        notFoundContent={null}
                                                        onSearch={this.handleWardSelectData}
                                                        placeholder="搜索供应商"
                                                        allowClear
                                                        style={{ width: '100%' }}
                                                        onChange={this.handleWardOnChange}
                                                    >
                                                        {wardAreaOption}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8} style={{ paddingRight: '10px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingcreateDate ? ChineseEnglishSize.WarehousingOrderMakingcreateDate.descripts : '入库日期'} {...formItemInput}>
                                                {getFieldDecorator('createDate', {
                                                    initialValue: userInfo.createDate ? Moment(userInfo.createDate, 'YYYY-MM-DD') : Moment(),
                                                })(
                                                    <DatePicker style={{ width: '100%' }} format="YYYY-MM-DD" allowClear disabled />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8} style={{ paddingRight: '30px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingremark ? ChineseEnglishSize.WarehousingOrderMakingremark.descripts : '入库备注'} {...formItemInput}>
                                                {getFieldDecorator('remark', {
                                                    initialValue: userInfo.remark ? userInfo.remark : undefined,
                                                })(
                                                    <Input placeholder={ChineseEnglishSize.WarehousingOrderMakinginputTips && ChineseEnglishSize.WarehousingOrderMakingremark ? (ChineseEnglishSize.WarehousingOrderMakinginputTips.descripts + ChineseEnglishSize.WarehousingOrderMakingremark.descripts) : '请输入入库备注'} ref={this.myRef5} onPressEnter={() => this.handleOnSelect(5)} />
                                                )}
                                            </Form.Item>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={8} style={{ paddingRight: '10px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingstkCatID ? ChineseEnglishSize.WarehousingOrderMakingstkCatID.descripts : '库存大类'} {...formItemInput}>
                                                {getFieldDecorator('stkCatID', {
                                                    initialValue: userInfo.stkCatID ? userInfo.stkCatID : undefined,
                                                })(
                                                    <Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.WarehousingOrderMakingpleaseChoose && ChineseEnglishSize.WarehousingOrderMakingstkCatID ? (ChineseEnglishSize.WarehousingOrderMakingpleaseChoose.descripts + ChineseEnglishSize.WarehousingOrderMakingstkCatID.descripts) : '请选择库存大类'} ref={this.myRef6} onSelect={(v) => { this.handleOnSelect(6); this.changeStkCat(v) }}>
                                                        {this.state.SelectData.stkCat && this.state.SelectData.stkCat.map(item => {
                                                            return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8} style={{ paddingRight: '10px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakinginOperNo ? ChineseEnglishSize.WarehousingOrderMakinginOperNo.descripts : '入库单号'} {...formItemInput}>
                                                {getFieldDecorator('No', {
                                                    initialValue: userInfo.No ? userInfo.No : undefined,
                                                })(
                                                    <Input placeholder={ChineseEnglishSize.WarehousingOrderMakingNoTips ? ChineseEnglishSize.WarehousingOrderMakingNoTips.descripts : '保存成功后生成入库单号'} disabled />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={4}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakinggiftFlag ? ChineseEnglishSize.WarehousingOrderMakinggiftFlag.descripts : '赠送标志'} {...formItemSwitch}>
                                                {getFieldDecorator('giftFlag', {
                                                    valuePropName: 'checked',
                                                    initialValue: userInfo.giftFlag === "Y" ? true : false,
                                                })(

                                                    this.state.language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" ref={this.myRef7} onChange={() => this.handleOnSelect(7)} /> : <Switch checkedChildren="是" unCheckedChildren="否" ref={this.myRef7} onChange={() => this.handleOnSelect(7)} />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={4}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingadjCheque ? ChineseEnglishSize.WarehousingOrderMakingadjCheque.descripts : '调价换票'} {...formItemSwitch}>
                                                {getFieldDecorator('adjCheque', {
                                                    valuePropName: 'checked',
                                                    initialValue: userInfo.adjCheque === "Y" ? true : false,
                                                })(
                                                    this.state.language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" ref={this.myRef9} onChange={() => this.handleOnSelect(9)} /> : <Switch checkedChildren="是" unCheckedChildren="否" ref={this.myRef9} onChange={() => this.handleOnSelect(9)} />

                                                )}
                                            </Form.Item>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={8} style={{ paddingRight: '10px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingtoLoc ? ChineseEnglishSize.WarehousingOrderMakingtoLoc.descripts : '请求科室'} {...formItemInput}>
                                                {getFieldDecorator('reqLocID', {
                                                    initialValue: userInfo.reqLocID ? userInfo.reqLocID : undefined,
                                                })(
                                                    <Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.WarehousingOrderMakingpleaseChoose && ChineseEnglishSize.WarehousingOrderMakingtoLoc ? (ChineseEnglishSize.WarehousingOrderMakingpleaseChoose.descripts + ChineseEnglishSize.WarehousingOrderMakingtoLoc.descripts) : '请选择请求科室'} ref={this.myRef8} onSelect={() => this.handleOnSelect(8)}>
                                                        {this.state.SelectData.reqLoc && this.state.SelectData.reqLoc.map(item => {
                                                            return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8} style={{ paddingRight: '10px' }}>
                                            <Form.Item label={ChineseEnglishSize.WarehousingOrderMakingstatus ? ChineseEnglishSize.WarehousingOrderMakingstatus.descripts : '单据状态'} {...formItemInput}>
                                                {getFieldDecorator('statusID', {
                                                    initialValue: userInfo.statusID ? userInfo.statusID : undefined,
                                                })(
                                                    <Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.WarehousingOrderMakingunsaved ? ChineseEnglishSize.WarehousingOrderMakingunsaved.descripts : '未保存'} disabled>
                                                        {this.state.SelectData.inOpStatus && this.state.SelectData.inOpStatus.map(item => {
                                                            return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8} style={{ paddingLeft: '8%', marginTop: '3px' }}>
                                            <Dropdown overlay={menu} placement="bottomLeft">
                                                <Button> {ChineseEnglishSize.WarehousingOrderMakinginboundAuxliary ? ChineseEnglishSize.WarehousingOrderMakinginboundAuxliary.descripts : '入库辅助制单'}</Button>
                                            </Dropdown>
                                        </Col>
                                    </Row>
                                </Form>
                            </Col>
                            <Col span={6}>
                                <Row style={{ marginBottom: '18px' }}>
                                    <Button style={{ marginRight: '30px' }} onClick={this.inquireHandle}> {ChineseEnglishSize.WarehousingOrderMakingsearch ? ChineseEnglishSize.WarehousingOrderMakingsearch.descripts : '查询'}</Button>
                                    <Popconfirm title={ChineseEnglishSize.WarehousingOrderMakingresetTips ? ChineseEnglishSize.WarehousingOrderMakingresetTips.descripts : "重置后将初始化数据，你确定要重置吗?"} onConfirm={this.resetFields} >
                                        <Button> {ChineseEnglishSize.WarehousingOrderMakingReset ? ChineseEnglishSize.WarehousingOrderMakingReset.descripts : '重置'}</Button>
                                    </Popconfirm>
                                </Row>
                                <Row style={{ marginBottom: '18px' }}>
                                    <Button type="primary" style={{ marginRight: '30px' }} onClick={this.saveHandle}> {ChineseEnglishSize.WarehousingOrderMakingsave ? ChineseEnglishSize.WarehousingOrderMakingsave.descripts : '保存'}</Button>
                                    <Popconfirm title={ChineseEnglishSize.WarehousingOrderMakingdeleteTips ? ChineseEnglishSize.WarehousingOrderMakingdeleteTips.descripts : "删除不可恢复，你确定要删除吗?"} onConfirm={this.handleDelete} >
                                        <Button type="danger"> {ChineseEnglishSize.WarehousingOrderMakingdelete ? ChineseEnglishSize.WarehousingOrderMakingdelete.descripts : '删除'}</Button>
                                    </Popconfirm>
                                </Row>
                                <Row style={{ marginBottom: '18px' }}>
                                    <Button type="primary" style={{ marginRight: '30px' }}
                                        onClick={this.handleComplete}
                                        disabled={!this.state.rowId || completeStatus}> {ChineseEnglishSize.WarehousingOrderMakingaccomplish ? ChineseEnglishSize.WarehousingOrderMakingaccomplish.descripts : '完成'}</Button>
                                    <Button type="danger"
                                        onClick={this.handleCancelComplete}
                                        disabled={!this.state.rowId || cancelCompleteStatus}> {ChineseEnglishSize.WarehousingOrderMakingcancelComplete ? ChineseEnglishSize.WarehousingOrderMakingcancelComplete.descripts : '取消完成'}</Button>
                                </Row>
                                <Row style={{ marginBottom: '18px' }}>
                                    <Button type="dashed" style={{ marginRight: '30px' }} onClick={printInOp.bind(this, this.state.rowId)}> {ChineseEnglishSize.WarehousingOrderMakingprint ? ChineseEnglishSize.WarehousingOrderMakingprint.descripts : '打印'}</Button>
                                    <Upload {...uploadprops}>
                                        <Tooltip title={ChineseEnglishSize.WarehousingOrderMakingimportTips ? ChineseEnglishSize.WarehousingOrderMakingimportTips.descripts : '导入excel文件'}>
                                            <Button type="dashed" >
                                                <Icon type="import" />  {ChineseEnglishSize.WarehousingOrderMakingimport ? ChineseEnglishSize.WarehousingOrderMakingimport.descripts : '导入'}
                                            </Button>
                                        </Tooltip>
                                    </Upload>
                                </Row>
                            </Col>
                        </Row>
                    </Card>
                    <DetailEntryList SelectData={this.state.SelectData} onRef={this.detailOnRef} mainInfo={this.state.userInfo} detailInfo={this.state.detailInfo} handleThis={this} inOperLocID={this.state.inOperLocID} stkCatID={this.state.stkCatID} />
                    <InquireWarehouseVoucher SelectData={this.state.SelectData} onRef={this.onRef} inOperLocID={this.state.inOperLocID} handleThis={this} />
                    <AccordingToWarehouse onRef={this.onWarehouseRef} handleThis={this} />
                    <AccordingToChecked onRef={this.onCheckedRef} handleThis={this} />
                </div>
            )
        }
    }
);

export default WarehouseVoucher;
